4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * http://www.gnu.org/copyleft/gpl.html
20 class SpecialPreferences
extends SpecialPage
{
21 function __construct() {
22 parent
::__construct( 'Preferences' );
25 function execute( $par ) {
26 global $wgOut, $wgUser, $wgRequest;
29 $this->outputHeader();
30 $wgOut->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
32 if ( $wgUser->isAnon() ) {
33 $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext', array( $this->getTitle()->getPrefixedDBkey() ) );
37 $wgOut->readOnlyPage();
41 if ( $par == 'reset' ) {
42 $this->showResetForm();
46 $wgOut->addScriptFile( 'prefs.js' );
48 if ( $wgRequest->getCheck( 'success' ) ) {
50 "<div class=\"successbox\"><strong>\n$1\n</strong></div><div id=\"mw-pref-clear\"></div>",
55 if ( $wgRequest->getCheck( 'eauth' ) ) {
56 $wgOut->wrapWikiMsg( "<div class='error' style='clear: both;'>\n$1\n</div>",
57 'eauthentsent', $wgUser->getName() );
60 $htmlForm = Preferences
::getFormObject( $wgUser );
61 $htmlForm->setSubmitCallback( array( 'Preferences', 'tryUISubmit' ) );
66 function showResetForm() {
69 $wgOut->addWikiMsg( 'prefs-reset-intro' );
71 $htmlForm = new HTMLForm( array(), 'prefs-restore' );
73 $htmlForm->setSubmitText( wfMsg( 'restoreprefs' ) );
74 $htmlForm->setTitle( $this->getTitle( 'reset' ) );
75 $htmlForm->setSubmitCallback( array( __CLASS__
, 'submitReset' ) );
76 $htmlForm->suppressReset();
81 static function submitReset( $formData ) {
82 global $wgUser, $wgOut;
83 $wgUser->resetOptions();
84 $wgUser->saveSettings();
86 $url = SpecialPage
::getTitleFor( 'Preferences' )->getFullURL( 'success' );
88 $wgOut->redirect( $url );